<!-- HTML header for doxygen 1.8.13-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.8.13"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>MTB CAT1 Peripheral driver library: Functions</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<script type="text/javascript">
  $(document).ready(initResizable);
</script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen_style.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectlogo"><a href="http://www.cypress.com/"><img alt="Logo" src="IFXCYP_one-line.png"/></a></td>
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">MTB CAT1 Peripheral driver library</div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.8.13 -->
<script type="text/javascript">
var searchBox = new SearchBox("searchBox", "search",false,'Search');
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
$(function() {
  initMenu('',true,false,'search.php','Search');
  $(document).ready(function() { init_search(); });
});
</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
$(document).ready(function(){initNavTree('group__group__ipc__sema__functions.html','');});
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#func-members">Functions</a>  </div>
  <div class="headertitle">
<div class="title">Functions<div class="ingroups"><a class="el" href="group__group__ipc.html">IPC          (Inter Process Communication)</a> &raquo; <a class="el" href="group__group__ipc__sema.html">IPC semaphores layer (IPC_SEMA)</a></div></div>  </div>
</div><!--header-->
<div class="contents">
<a name="details" id="details"></a><h2 class="groupheader">General Description</h2>
<p>Functions are used in the driver. </p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
Functions</h2></td></tr>
<tr class="memitem:ga1cbc3b147c650c8716de10a1ee8423bd"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__ipc__sema__enums.html#ga64ee08d87c6d84e39749834cbdd6b7b9">cy_en_ipcsema_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__ipc__sema__functions.html#ga1cbc3b147c650c8716de10a1ee8423bd">Cy_IPC_Sema_Init</a> (uint32_t ipcChannel, uint32_t count, uint32_t memPtr[])</td></tr>
<tr class="memdesc:ga1cbc3b147c650c8716de10a1ee8423bd"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function initializes the semaphores subsystem.  <a href="#ga1cbc3b147c650c8716de10a1ee8423bd">More...</a><br /></td></tr>
<tr class="separator:ga1cbc3b147c650c8716de10a1ee8423bd"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga84360b76b923e0c249832a0c7690d589"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__ipc__sema__enums.html#ga64ee08d87c6d84e39749834cbdd6b7b9">cy_en_ipcsema_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__ipc__sema__functions.html#ga84360b76b923e0c249832a0c7690d589">Cy_IPC_Sema_InitExt</a> (uint32_t ipcChannel, <a class="el" href="structcy__stc__ipc__sema__t.html">cy_stc_ipc_sema_t</a> *ipcSema)</td></tr>
<tr class="memdesc:ga84360b76b923e0c249832a0c7690d589"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function initializes the semaphores subsystem.  <a href="#ga84360b76b923e0c249832a0c7690d589">More...</a><br /></td></tr>
<tr class="separator:ga84360b76b923e0c249832a0c7690d589"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ga455867cd3b817d61d355f0407221a9a9"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__ipc__sema__enums.html#ga64ee08d87c6d84e39749834cbdd6b7b9">cy_en_ipcsema_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__ipc__sema__functions.html#ga455867cd3b817d61d355f0407221a9a9">Cy_IPC_Sema_Set</a> (uint32_t semaNumber, bool preemptable)</td></tr>
<tr class="memdesc:ga455867cd3b817d61d355f0407221a9a9"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function tries to acquire a semaphore.  <a href="#ga455867cd3b817d61d355f0407221a9a9">More...</a><br /></td></tr>
<tr class="separator:ga455867cd3b817d61d355f0407221a9a9"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaec88ff547d0d3185e7336c78a7411781"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__ipc__sema__enums.html#ga64ee08d87c6d84e39749834cbdd6b7b9">cy_en_ipcsema_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__ipc__sema__functions.html#gaec88ff547d0d3185e7336c78a7411781">Cy_IPC_Sema_Clear</a> (uint32_t semaNumber, bool preemptable)</td></tr>
<tr class="memdesc:gaec88ff547d0d3185e7336c78a7411781"><td class="mdescLeft">&#160;</td><td class="mdescRight">This functions tries to releases a semaphore.  <a href="#gaec88ff547d0d3185e7336c78a7411781">More...</a><br /></td></tr>
<tr class="separator:gaec88ff547d0d3185e7336c78a7411781"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaaa39cd088ef1e2ee9cd0555ae733c98f"><td class="memItemLeft" align="right" valign="top"><a class="el" href="group__group__ipc__sema__enums.html#ga64ee08d87c6d84e39749834cbdd6b7b9">cy_en_ipcsema_status_t</a>&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__ipc__sema__functions.html#gaaa39cd088ef1e2ee9cd0555ae733c98f">Cy_IPC_Sema_Status</a> (uint32_t semaNumber)</td></tr>
<tr class="memdesc:gaaa39cd088ef1e2ee9cd0555ae733c98f"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function returns the status of the semaphore.  <a href="#gaaa39cd088ef1e2ee9cd0555ae733c98f">More...</a><br /></td></tr>
<tr class="separator:gaaa39cd088ef1e2ee9cd0555ae733c98f"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:gaf8dd9fc553a66939d37a988fa17eb3c1"><td class="memItemLeft" align="right" valign="top">uint32_t&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__group__ipc__sema__functions.html#gaf8dd9fc553a66939d37a988fa17eb3c1">Cy_IPC_Sema_GetMaxSems</a> (void)</td></tr>
<tr class="memdesc:gaf8dd9fc553a66939d37a988fa17eb3c1"><td class="mdescLeft">&#160;</td><td class="mdescRight">This function returns the number of semaphores in the semaphores subsystem.  <a href="#gaf8dd9fc553a66939d37a988fa17eb3c1">More...</a><br /></td></tr>
<tr class="separator:gaf8dd9fc553a66939d37a988fa17eb3c1"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<h2 class="groupheader">Function Documentation</h2>
<a id="ga1cbc3b147c650c8716de10a1ee8423bd"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga1cbc3b147c650c8716de10a1ee8423bd">&#9670;&nbsp;</a></span>Cy_IPC_Sema_Init()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__ipc__sema__enums.html#ga64ee08d87c6d84e39749834cbdd6b7b9">cy_en_ipcsema_status_t</a> Cy_IPC_Sema_Init </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>ipcChannel</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>count</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>memPtr</em>[]&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function initializes the semaphores subsystem. </p>
<p>The user must create an array of unsigned 32-bit words to hold the semaphore bits. The number of semaphores will be the size of the array * 32. The total semaphores count will always be a multiple of 32.</p>
<dl class="section note"><dt>Note</dt><dd>In a multi-CPU system this init function should be called with all initialized parameters on one CPU only to provide a pointer to SRAM that can be shared between all the CPUs in the system that will use semaphores. On other CPUs user must specify the IPC semaphores channel and pass 0 / NULL to count and memPtr parameters correspondingly.</dd></dl>
<p>CM7 cores in CAT1C devices support Data Cache. Data Cache line is 32 bytes. User needs to make sure that the memPtr pointer passed to the Cy_IPC_Sema_Init function points to 32 byte aligned array of words that contain the semaphore data. User can use CY_ALIGN(32) macro for 32 byte alignment.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ipcChannel</td><td>The IPC channel number used for semaphores</td></tr>
    <tr><td class="paramname">count</td><td>The maximum number of semaphores to be supported (multiple of 32).</td></tr>
    <tr><td class="paramname">memPtr</td><td>This points to the array of (count/32) words that contain the semaphore data.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Status of the operation </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">CY_IPC_SEMA_SUCCESS</td><td>Successfully initialized </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_BAD_PARAM</td><td>Memory pointer is NULL and count is not zero, or count not multiple of 32 </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_ERROR_LOCKED</td><td>Could not acquire semaphores IPC channel</td></tr>
  </table>
  </dd>
</dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line">    <span class="comment">/* Scenario: set up a single semaphore channel for use in communicating between two cores */</span></div><div class="line"><span class="preprocessor">    #ifndef MY_IPC_CHAN_INDEX</span></div><div class="line"><span class="preprocessor">        #define MY_IPC_CHAN_INDEX        (8UL) </span><span class="comment">/* Example of IPC channel index */</span><span class="preprocessor"></span></div><div class="line"><span class="preprocessor">    #endif </span><span class="comment">/* MY_IPC_CHAN_INDEX */</span><span class="preprocessor"></span></div><div class="line"></div><div class="line"><span class="preprocessor">#if (CY_CPU_CORTEX_M0P)</span></div><div class="line">    <span class="comment">/* The semaphore data is usually allocated in CM0+ memory space */</span></div><div class="line">    uint32_t mySemaData; <span class="comment">/* So there are 32 semaphores */</span></div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a3aa7b86b286b7666ee4482ae040d6d1b">CY_IPC_SEMA_SUCCESS</a> != <a class="code" href="group__group__ipc__sema__functions.html#ga1cbc3b147c650c8716de10a1ee8423bd">Cy_IPC_Sema_Init</a>(MY_IPC_CHAN_INDEX, 32UL, &amp;mySemaData))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Handle possible errors */</span></div><div class="line">    }</div><div class="line"><span class="preprocessor">#else</span></div><div class="line">    <span class="comment">/* Therefore, another core (usually CM4, CM7_0 or CM7_1) initializes semaphore subsystem without data pointer */</span></div><div class="line">    <span class="keywordflow">if</span> (<a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a3aa7b86b286b7666ee4482ae040d6d1b">CY_IPC_SEMA_SUCCESS</a> != <a class="code" href="group__group__ipc__sema__functions.html#ga1cbc3b147c650c8716de10a1ee8423bd">Cy_IPC_Sema_Init</a>(MY_IPC_CHAN_INDEX, 0UL, NULL))</div><div class="line">    {</div><div class="line">        <span class="comment">/* Handle possible errors */</span></div><div class="line">    }</div><div class="line"><span class="preprocessor">#endif  </span><span class="comment">/* (CY_CPU_CORTEX_M0P) */</span><span class="preprocessor"></span></div></div><!-- fragment --></dd></dl>

</div>
</div>
<a id="ga84360b76b923e0c249832a0c7690d589"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga84360b76b923e0c249832a0c7690d589">&#9670;&nbsp;</a></span>Cy_IPC_Sema_InitExt()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__ipc__sema__enums.html#ga64ee08d87c6d84e39749834cbdd6b7b9">cy_en_ipcsema_status_t</a> Cy_IPC_Sema_InitExt </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>ipcChannel</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype"><a class="el" href="structcy__stc__ipc__sema__t.html">cy_stc_ipc_sema_t</a> *&#160;</td>
          <td class="paramname"><em>ipcSema</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function initializes the semaphores subsystem. </p>
<p>The user must create an array of unsigned 32-bit words to hold the semaphore bits. The number of semaphores will be the size of the array * 32. The total semaphores count will always be a multiple of 32.</p>
<dl class="section note"><dt>Note</dt><dd>In a multi-CPU system this init function should be called with all initialized parameters on one CPU only to provide a pointer to SRAM that can be shared between all the CPUs in the system that will use semaphores. On other CPUs user must specify the IPC semaphores channel and pass 0 / NULL to count and memPtr parameters correspondingly.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">ipcChannel</td><td>The IPC channel number used for semaphores</td></tr>
    <tr><td class="paramname">ipcSema</td><td>This is configuration structure of the IPC semaphore. See <a class="el" href="structcy__stc__ipc__sema__t.html">cy_stc_ipc_sema_t</a>.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section return"><dt>Returns</dt><dd>Status of the operation </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">CY_IPC_SEMA_SUCCESS</td><td>Successfully initialized </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_BAD_PARAM</td><td>Memory pointer is NULL and count is not zero, or count not multiple of 32 </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_ERROR_LOCKED</td><td>Could not acquire semaphores IPC channel </td></tr>
  </table>
  </dd>
</dl>

</div>
</div>
<a id="ga455867cd3b817d61d355f0407221a9a9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ga455867cd3b817d61d355f0407221a9a9">&#9670;&nbsp;</a></span>Cy_IPC_Sema_Set()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__ipc__sema__enums.html#ga64ee08d87c6d84e39749834cbdd6b7b9">cy_en_ipcsema_status_t</a> Cy_IPC_Sema_Set </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>semaNumber</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>preemptable</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function tries to acquire a semaphore. </p>
<p>If the semaphore is not available, this function returns immediately with CY_IPC_SEMA_LOCKED.</p>
<p>It first acquires the IPC channel that is used for all the semaphores, sets the semaphore if it is cleared, then releases the IPC channel used for the semaphore.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">semaNumber</td><td>The semaphore number to acquire. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>CAT1D has two shared memories. One is a secure memory area which is accessible from secure domains only. Another memory area which is accessible from both secure and non-secure domains. To use secure area for semaphore, user has to use <a class="el" href="group__group__ipc__sema__macros.html#gaeee9d0615136825d9e421cc0d579357c">CY_IPC_SEMA_SEC</a> macro to create a secure semaphore.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">preemptable</td><td>When this parameter is enabled the function can be preempted by another task or other forms of context switching in an RTOS environment.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>If <b>preemptable</b> is enabled (true), the user must ensure that there are no deadlocks in the system, which can be caused by an interrupt that occurs after the IPC channel is locked. Unless the user is ready to handle IPC channel locks correctly at the application level, set <b>preemptable</b> to false.</dd></dl>
<dl class="section return"><dt>Returns</dt><dd>Status of the operation </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">CY_IPC_SEMA_SUCCESS</td><td>The semaphore was set successfully </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_LOCKED</td><td>The semaphore channel is busy or locked by another process </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_NOT_ACQUIRED</td><td>Semaphore was already set </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_OUT_OF_RANGE</td><td>The semaphore number is not valid</td></tr>
  </table>
  </dd>
</dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line">    <span class="comment">/* Scenario: set semaphore #MY_SEMA_NUM to inform the other core</span></div><div class="line"><span class="comment">     * of the intention to perform some action.</span></div><div class="line"><span class="comment">     */</span></div><div class="line"><span class="preprocessor">    #define MY_SEMA_NUM (3UL)</span></div><div class="line"></div><div class="line">    <span class="keywordflow">switch</span> (<a class="code" href="group__group__ipc__sema__functions.html#ga455867cd3b817d61d355f0407221a9a9">Cy_IPC_Sema_Set</a>(MY_SEMA_NUM, <span class="keyword">false</span>))</div><div class="line">    {</div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a3aa7b86b286b7666ee4482ae040d6d1b">CY_IPC_SEMA_SUCCESS</a>:</div><div class="line">            <span class="comment">/* The semaphore is set successfully */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a626c7f517e6dbd4f20281b4fa42300ed">CY_IPC_SEMA_LOCKED</a>:</div><div class="line">            <span class="comment">/* The semaphore channel is busy or locked by another process */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a21f1c980ff46f66bd0bef3ff5958204b">CY_IPC_SEMA_NOT_ACQUIRED</a>:</div><div class="line">            <span class="comment">/* Semaphore is already set */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a143eff28bd0bc98a860fce473075d1ac">CY_IPC_SEMA_OUT_OF_RANGE</a>:</div><div class="line">            <span class="comment">/* The semaphore number is not valid */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">default</span>: <span class="keywordflow">break</span>;</div><div class="line">    }</div></div><!-- fragment --></dd></dl>
<p>check cy_semaIpcStruct != NULL </p>

</div>
</div>
<a id="gaec88ff547d0d3185e7336c78a7411781"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaec88ff547d0d3185e7336c78a7411781">&#9670;&nbsp;</a></span>Cy_IPC_Sema_Clear()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__ipc__sema__enums.html#ga64ee08d87c6d84e39749834cbdd6b7b9">cy_en_ipcsema_status_t</a> Cy_IPC_Sema_Clear </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>semaNumber</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">bool&#160;</td>
          <td class="paramname"><em>preemptable</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This functions tries to releases a semaphore. </p>
<p>It first acquires the IPC channel that is used for all the semaphores, clears the semaphore if it is set, then releases the IPC channel used for the semaphores.</p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">semaNumber</td><td>The index of the semaphore to release. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>CAT1D has two shared memories. One is a secure memory area which is accessible from secure domains only. Another memory area which is accessible from both secure and non-secure domains. To use secure area for semaphore, user has to use <a class="el" href="group__group__ipc__sema__macros.html#gaeee9d0615136825d9e421cc0d579357c">CY_IPC_SEMA_SEC</a> macro to create a secure semaphore.</dd></dl>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">preemptable</td><td>When this parameter is enabled the function can be preempted by another task or other forms of context switching in an RTOS environment.</td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>If <b>preemptable</b> is enabled (true), the user must ensure that there are no deadlocks in the system, which can be caused by an interrupt that occurs after the IPC channel is locked. Unless the user is ready to handle IPC channel locks correctly at the application level, set <b>preemptable</b> to false.</dd></dl>
<dl class="section return"><dt>Returns</dt><dd>Status of the operation </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">CY_IPC_SEMA_SUCCESS</td><td>The semaphore was cleared successfully </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_NOT_ACQUIRED</td><td>The semaphore was already cleared </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_LOCKED</td><td>The semaphore channel was semaphored or busy </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_OUT_OF_RANGE</td><td>The semaphore number is not valid</td></tr>
  </table>
  </dd>
</dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line">    <span class="comment">/* Scenario: action is completed. Clear the semaphore #MY_SEMA_NUM to inform</span></div><div class="line"><span class="comment">     * the other core that the action is already completed.</span></div><div class="line"><span class="comment">     */</span></div><div class="line"><span class="preprocessor">    #define MY_SEMA_NUM (3UL)</span></div><div class="line"></div><div class="line">    <span class="keywordflow">switch</span> (<a class="code" href="group__group__ipc__sema__functions.html#gaec88ff547d0d3185e7336c78a7411781">Cy_IPC_Sema_Clear</a>(MY_SEMA_NUM, <span class="keyword">false</span>))</div><div class="line">    {</div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a3aa7b86b286b7666ee4482ae040d6d1b">CY_IPC_SEMA_SUCCESS</a>:</div><div class="line">            <span class="comment">/* The semaphore is cleared successfully */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a626c7f517e6dbd4f20281b4fa42300ed">CY_IPC_SEMA_LOCKED</a>:</div><div class="line">            <span class="comment">/* The semaphore channel is busy or locked by another process */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a21f1c980ff46f66bd0bef3ff5958204b">CY_IPC_SEMA_NOT_ACQUIRED</a>:</div><div class="line">            <span class="comment">/*Semaphore is already cleared */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a143eff28bd0bc98a860fce473075d1ac">CY_IPC_SEMA_OUT_OF_RANGE</a>:</div><div class="line">            <span class="comment">/* The semaphore number is not valid */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">default</span>: <span class="keywordflow">break</span>;</div><div class="line">    }</div></div><!-- fragment --></dd></dl>
<p>check cy_semaIpcStruct != NULL </p>

</div>
</div>
<a id="gaaa39cd088ef1e2ee9cd0555ae733c98f"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaaa39cd088ef1e2ee9cd0555ae733c98f">&#9670;&nbsp;</a></span>Cy_IPC_Sema_Status()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname"><a class="el" href="group__group__ipc__sema__enums.html#ga64ee08d87c6d84e39749834cbdd6b7b9">cy_en_ipcsema_status_t</a> Cy_IPC_Sema_Status </td>
          <td>(</td>
          <td class="paramtype">uint32_t&#160;</td>
          <td class="paramname"><em>semaNumber</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function returns the status of the semaphore. </p>
<dl class="params"><dt>Parameters</dt><dd>
  <table class="params">
    <tr><td class="paramname">semaNumber</td><td>The index of the semaphore to return status. </td></tr>
  </table>
  </dd>
</dl>
<dl class="section note"><dt>Note</dt><dd>CAT1D has two shared memories. One is a secure memory area which is accessible from secure domains only. Another memory area which is accessible from both secure and non-secure domains. To use secure area for semaphore, user has to use <a class="el" href="group__group__ipc__sema__macros.html#gaeee9d0615136825d9e421cc0d579357c">CY_IPC_SEMA_SEC</a> macro to create a secure semaphore.</dd></dl>
<dl class="section return"><dt>Returns</dt><dd>Status of the operation </dd></dl>
<dl class="retval"><dt>Return values</dt><dd>
  <table class="retval">
    <tr><td class="paramname">CY_IPC_SEMA_STATUS_LOCKED</td><td>The semaphore is in the set state. </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_STATUS_UNLOCKED</td><td>The semaphore is in the cleared state. </td></tr>
    <tr><td class="paramname">CY_IPC_SEMA_OUT_OF_RANGE</td><td>The semaphore number is not valid</td></tr>
  </table>
  </dd>
</dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line">    <span class="comment">/* Scenario: check the state of semaphore #3. */</span></div><div class="line"><span class="preprocessor">    #define MY_SEMA_NUM (3UL)</span></div><div class="line"></div><div class="line">    <span class="keywordflow">switch</span> (<a class="code" href="group__group__ipc__sema__functions.html#gaaa39cd088ef1e2ee9cd0555ae733c98f">Cy_IPC_Sema_Status</a>(MY_SEMA_NUM))</div><div class="line">    {</div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a920300a84a7ca2e96ce187423ac2eb18">CY_IPC_SEMA_STATUS_LOCKED</a>:</div><div class="line">            <span class="comment">/* The semaphore is in the set state */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9af009b6acf4579107d5384100f9f2e60c">CY_IPC_SEMA_STATUS_UNLOCKED</a>:</div><div class="line">            <span class="comment">/* The semaphore is in the cleared state */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">case</span> <a class="code" href="group__group__ipc__sema__enums.html#gga64ee08d87c6d84e39749834cbdd6b7b9a143eff28bd0bc98a860fce473075d1ac">CY_IPC_SEMA_OUT_OF_RANGE</a>:</div><div class="line">            <span class="comment">/* The semaphore number is not valid */</span></div><div class="line">            <span class="keywordflow">break</span>;</div><div class="line"></div><div class="line">        <span class="keywordflow">default</span>: <span class="keywordflow">break</span>;</div><div class="line">    }</div></div><!-- fragment --></dd></dl>
<p>check cy_semaIpcStruct != NULL </p>

</div>
</div>
<a id="gaf8dd9fc553a66939d37a988fa17eb3c1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#gaf8dd9fc553a66939d37a988fa17eb3c1">&#9670;&nbsp;</a></span>Cy_IPC_Sema_GetMaxSems()</h2>

<div class="memitem">
<div class="memproto">
      <table class="memname">
        <tr>
          <td class="memname">uint32_t Cy_IPC_Sema_GetMaxSems </td>
          <td>(</td>
          <td class="paramtype">void&#160;</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
</div><div class="memdoc">

<p>This function returns the number of semaphores in the semaphores subsystem. </p>
<dl class="section return"><dt>Returns</dt><dd>Returns the semaphores quantity.</dd></dl>
<dl class="section user"><dt>Function Usage</dt><dd><div class="fragment"><div class="line">    <span class="comment">/* Scenario: get the maximum number of configured semaphores</span></div><div class="line"><span class="comment">     * and check if the MY_SEMA_NUM is valid.</span></div><div class="line"><span class="comment">     */</span></div><div class="line"><span class="preprocessor">    #define MY_SEMA_NUM (3UL)</span></div><div class="line"></div><div class="line">    <span class="keywordflow">if</span> (MY_SEMA_NUM &lt; <a class="code" href="group__group__ipc__sema__functions.html#gaf8dd9fc553a66939d37a988fa17eb3c1">Cy_IPC_Sema_GetMaxSems</a>())</div><div class="line">    {</div><div class="line">        <span class="comment">/* The MY_SEMA_NUM is valid */</span></div><div class="line">    }</div></div><!-- fragment --></dd></dl>

</div>
</div>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part
<div id="nav-path" class="navpath">
    <ul>
        <li class="footer">
            Generated for <b>MTB CAT1 Peripheral driver library</b> by <b>Cypress Semiconductor Corporation</b>.
            All rights reserved.
        </li>
    </ul>
</div>
-->
</body>
</html>
